import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *
testCase = "DBshop0011_商品管理-添加商品"
# 1. 打开后台网站
firefox=openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
# 2.添加商品
DBshopEnterMenu2(firefox,"商品管理","管理商品")
firefox.find_element_by_link_text("添加商品").click()
firefox.find_element_by_id("goods_name").send_keys("苹果XR")
firefox.find_element_by_id("goods_shop_price").send_keys(7999)
from selenium.webdriver.support.select import Select
s1 = Select(firefox.find_element_by_id("goods_type"))
s1.select_by_visible_text("虚拟商品")
# 3.保存商品
firefox.find_element_by_xpath("/html/body/div[2]/div/div[2]/div/form/div/div[1]/div[2]/button").click()
# 断言
if firefox.find_element_by_xpath("/html/body/div[2]/div/div[2]/table/tbody/tr[2]/td[3]"):
    writeLog("%s 测试通过" % testCase)
else:
    writeLog("%s 测试失败" % testCase)
    getPhoto(firefox)
firefox.quit()